﻿using Microsoft.EntityFrameworkCore;
using StockTrading.Triggers;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StockTrading.Model
{
    public class SqlServerDbContext: ApplicationDbContext
    {
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            //从配置文件中读取连接字符串
            string connection = ConfigurationManager.ConnectionStrings["StockTradingSqlServer"].ConnectionString;
            //推迟数据库加载到实际需要时
            optionsBuilder.EnableSensitiveDataLogging()
                .UseSqlServer(connection)
                .UseTriggers(x => x.AddTrigger<MatchMakingTrigger>()); ;
            base.OnConfiguring(optionsBuilder);
        }
    }
}
